cmake_minimum_required(VERSION 3.10)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 COMPONENTS Core Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Widgets  REQUIRED)

include_directories(${TASKBUS_INTERFACEDIR})
set(PRJ_HEADERS
	dialogpannel.h
listen_thread.h
)
set(PRJ_SOURCES
	main.cpp
	dialogpannel.cpp
listen_thread.cpp
)
set(PRJ_FORMS
	dialogpannel.ui
)
set(PRJ_RESOURCES
	control_pannel.qrc
)
#############Target======================
qt_add_executable(control_pannel
	MANUAL_FINALIZATION
	${PRJ_HEADERS}
	${PRJ_SOURCES}
	${PRJ_FORMS}
	${PRJ_RESOURCES}
)

target_link_libraries(control_pannel PRIVATE
	Qt${QT_VERSION_MAJOR}::Widgets
	${TBLinkExtra}
)

set_target_properties(control_pannel PROPERTIES
	MACOSX_BUNDLE_GUI_IDENTIFIER taskBus.modules.control_pannel
	MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
	MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
	MACOSX_BUNDLE TRUE
	WIN32_EXECUTABLE TRUE
)
qt_finalize_executable(control_pannel)

# ====copy doc
add_custom_command(TARGET control_pannel
		 POST_BUILD
		 COMMAND echo Copy Handbook to EXE path
		 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/control_pannel.md ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/control_pannel.md
	 )
